﻿//10. Write a program to calculate n! for each n in the range [1..100]. Hint: Implement first a method that multiplies a number represented as array of digits by given integer number. 


using System;
using System.Collections.Generic;

class NFactorial
{
    static void Main()
    {
        int numberN = int.Parse(Console.ReadLine());
        string firstNumber = "1";
        string secondNumber = "2";
        string numberNFactorial = "1";
        for (int i = 1; i < numberN; i++)
        {
            numberNFactorial = MultiplyNumbers(firstNumber, secondNumber);
            firstNumber = numberNFactorial;
            secondNumber = Convert.ToString(2 + i);
        }
        Console.WriteLine(numberNFactorial);
    }
    static string MultiplyNumbers(string firstNumber, string secondNumber)
    {
        char[] firstNumberAsDigits = firstNumber.ToCharArray();
        char[] secondNumberAsDigits = secondNumber.ToCharArray();
        int[] result = new int[firstNumberAsDigits.Length + secondNumberAsDigits.Length];
        int reminder = 0;
        int lastTwoSum = 0;
        for (int i = 0; i < firstNumberAsDigits.Length; i++)
        {
            lastTwoSum = (int)(firstNumberAsDigits[firstNumberAsDigits.Length - 1 - i] - '0') *
                (int)(secondNumberAsDigits[secondNumberAsDigits.Length - 1] - '0') + reminder;
            result[result.Length - 1 - i] = lastTwoSum % 10;
            reminder = lastTwoSum / 10;
            if (i == firstNumberAsDigits.Length - 1)
            {
                result[result.Length - 1 - i - 1] = reminder;
                break;
            }
        }
        int[] multiplyNumbers = new int[result.Length];
        for (int k = 1; k < secondNumber.Length; k++)
        {
            reminder = 0;
            for (int i = 0; i < firstNumberAsDigits.Length; i++)
            {
                lastTwoSum = (int)(firstNumberAsDigits[firstNumberAsDigits.Length - 1 - i] - '0') *
                    (int)(secondNumberAsDigits[secondNumberAsDigits.Length - 1 - k]- '0') + reminder;
                multiplyNumbers[multiplyNumbers.Length - 1 - i - k] = lastTwoSum % 10;
                reminder = lastTwoSum / 10;
                if (i == firstNumberAsDigits.Length - 1)
                {
                    multiplyNumbers[multiplyNumbers.Length - 1 - i - k - 1] = reminder;
                }
            }
            reminder = 0;
            for (int j = 0; j < result.Length; j++)
            {
                lastTwoSum = result[result.Length - 1 - j] + multiplyNumbers[multiplyNumbers.Length - 1 - j] + reminder;
                result[result.Length - 1 - j] = lastTwoSum % 10;
                reminder = lastTwoSum / 10;
            }
            Array.Clear(multiplyNumbers, 0, multiplyNumbers.Length);
        }
        char[] digitsSum = new char[result.Length];
        for (int i = 0; i < digitsSum.Length; i++)
        {
            digitsSum[i] = Convert.ToChar(Convert.ToString(result[i]));
        }
        string stringResult = new String(digitsSum);
        if (stringResult[0] == '0')
        {
            stringResult = stringResult.Substring(1, stringResult.Length - 1);
        }
        return stringResult;
    }
}
